Try this:
GeometryReader { geo in
Image(uiImage: UIImage(data: UserDefaults.standard.data(forKey: "ImageData")!)!)
.resizable()
.scaledToFill()
.frame(width: geo.size.width, height: geo.size.height)
.clipped()
}
Post
Replies
Boosts
Views
Activity
For me I would like know why only Apple Clock app Widget are allowed to dynamic moving? now It's Widget not icon right?
I'm not sure if there's a hard upper limit, but at some point usability or discoverability will be an issue for users. Users swipe through the widgets that your app offers in the gallery and if there are a lot it may be frustrating for users to find the widget that's useful to them.
How many are you considering having in your app? What would they all do? Can developer build an app that has a collection of widgets?Like Health Gallery, Quick Launch or Shortcuts? Or more themes? I'm not sure how it could take that number of widgets goes.
render it in your main app then save as an image and share it to widget to display.
You can use UIDevice in Widget Extension.
Na...you just can't!
Same issue here.
I know the issue is maybe I’m trying to access an element at index is out of the bounds of the array, but how can I avoid this because in my code I never use an array.
If you want to deal with widget margins with full responsibility
extension WidgetConfiguration
{
func contentMarginsDisabledIfAvailable() -> some WidgetConfiguration
{
if #available(iOSApplicationExtension 17.0, *)
{
return self.contentMarginsDisabled()
}
else
{
return self
}
}
}
@t9mike thanks, how do you compile your WidgetEntryView because .showsWidgetContainerBackground only available in iOS 17? and i have see those Xcode runtime error, so i tried a new approach but it couldn't work neither:
final class WidgetEnvironmentContext
{
static let shared = WidgetEnvironmentContext()
var showsWidgetContainerBackground: Bool = true
}
@available(iOS 17.0, *)
struct WidgetEnvironmentReader: View
{
@Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground: Bool
var body: some View {
WidgetEnvironmentContext.shared.showsWidgetContainerBackground = showsWidgetContainerBackground
return Color.clear
}
}
struct ExampleView: View
{
var body: some View {
ZStack {
if #available(iOS 17, *)
{
WidgetEnvironmentReader()
}
Text("Shows Background: \(WidgetEnvironmentContext.shared.showsWidgetContainerBackground ? "YES" : "NO")")
}
}
}
showsWidgetContainerBackground variable is randomly wrong in this way, i am so confuse now, i think i just use separate view in my code
struct WidgetView: View
{
var body: some View {
if #available(iOS 17, *)
{
HeaderView()
}
else
{
FallbackHeaderView()
}
...
}
}
Ok, after a little digging(actually a lot...), i think i finally have a solution, just in case anyone dealing the some issue:
// First we create a fallback variable environment
struct WidgetEnvShowsContainerBackgroundKey: EnvironmentKey
{
static let defaultValue: Bool = true
}
extension EnvironmentValues
{
var widgetEnvShowsContainerBackground: Bool {
set { self[WidgetEnvShowsContainerBackgroundKey.self] = newValue }
get { self[WidgetEnvShowsContainerBackgroundKey.self] }
}
}
extension View
{
func envShowsContainerBackground(_ value: Bool) -> some View
{
environment(\.widgetEnvShowsContainerBackground, value)
}
}
// Magic happens here
struct WidgetEnvironmentReader<Content: View>: View
{
var content: () -> Content
init(@ViewBuilder content: @escaping () -> Content)
{
self.content = content
}
var body: some View {
if #available(iOS 17.0, *)
{
WidgetEnvironmentViewBuilder(content: content)
}
else
{
content()
}
}
}
extension WidgetEnvironmentReader
{
@available(iOS 17.0, *)
struct WidgetEnvironmentViewBuilder<C: View>: View
{
@Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground
var content: () -> C
init(@ViewBuilder content: @escaping () -> C)
{
self.content = content
}
var body: some View {
content()
.envShowsContainerBackground(showsWidgetContainerBackground)
}
}
}
// Now we are free to use .showsWidgetContainerBackground in the older os version
@available(iOS 14.0, *)
struct WidgetView: View
{
@Environment(\.widgetEnvShowsContainerBackground) var widgetEnvShowsContainerBackground: Bool
var body: some View {
Text("Background: \(widgetEnvShowsContainerBackground ? "YES" : "No"), \(Date(), style: .relative)")
}
}
@available(iOS 14.0, *)
struct WidgetEntryView: View
{
let entry: Entry
var body: some View {
WidgetEnvironmentReader {
WidgetView()
}
.makeContainerBackground()
}
}
Same problem here, Xcode 15 beta and Xcode 15 RC, crash when trying upload app to notarize.
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Xcode [7242]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 15.0 (22265)
Build Info: IDEApplication-22265000000000000~3 (15A240d)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
User ID: 501
Date/Time: 2023-09-13 11:12:33.6172 +0800
OS Version: macOS 14.0 (23A339)
Report Version: 12
Anonymous UUID: 11BE4F5F-3C85-690B-0E16-188F1FDB7B73
Time Awake Since Boot: 2300 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: archive info plist lock
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process: Xcode [7242]
Application Specific Information:
com.apple.main-thread
abort() called
Application Specific Signatures:
(string) != nil
Thread 0 Crashed:: Dispatch queue: archive info plist lock
0 libsystem_kernel.dylib 0x190f6b11c __pthread_kill + 8
1 libsystem_pthread.dylib 0x190fa2cc0 pthread_kill + 288
2 libsystem_c.dylib 0x190eb2a50 abort + 180
3 IDEKit 0x107a38d58 +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 972
4 IDEKit 0x107a39198 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] + 872
5 DVTFoundation 0x103f299a8 _DVTAssertionHandler + 424
6 DVTFoundation 0x103f29b28 _DVTAssertionFailureHandler + 196
7 DVTFoundation 0x103dec3d4 +[DVTFilePath _filePathForParent:pathString:] + 360
8 DVTFoundation 0x103decb20 -[DVTFilePath filePathForRelativePathString:] + 48
9 IDEFoundation 0x10960286c -[IDEArchive _embedPackageFromDistributionRecord:error:] + 312
10 IDEFoundation 0x109602ea4 __36-[IDEArchive addDistribution:error:]_block_invoke + 56
11 libdispatch.dylib 0x190df5910 _dispatch_client_callout + 20
12 libdispatch.dylib 0x190e04cc4 _dispatch_lane_barrier_sync_invoke_and_complete + 56
13 DVTFoundation 0x103f70014 DVTDispatchBarrierSync + 148
14 DVTFoundation 0x103f4c2b4 -[DVTDispatchLock performLockedBlock:] + 60
15 IDEFoundation 0x109602d30 -[IDEArchive addDistribution:error:] + 200
16 IDEFoundation 0x1092a82f0 __35-[IDEDistributionUploadStep upload]_block_invoke.115 + 116
17 DVTFoundation 0x103f6f330 __DVT_CALLING_CLIENT_BLOCK__ + 16
18 DVTFoundation 0x103f6fb08 __DVTSyncPerformBlock_block_invoke + 68
19 CoreFoundation 0x19107f8c0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
20 CoreFoundation 0x19107f7d4 __CFRunLoopDoBlocks + 356
21 CoreFoundation 0x19107ec68 __CFRunLoopRun + 2440
22 CoreFoundation 0x19107dc2c CFRunLoopRunSpecific + 608
23 HIToolbox 0x19b5d6448 RunCurrentEventLoopInMode + 292
24 HIToolbox 0x19b5d6284 ReceiveNextEventCommon + 648
25 HIToolbox 0x19b5d5fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
26 AppKit 0x1948590ec _DPSNextEvent + 660
27 AppKit 0x19502cc2c -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
28 DVTKit 0x102de0a9c -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 300
29 AppKit 0x19484c598 -[NSApplication run] + 476
30 DVTKit 0x102ddfcbc -[DVTApplication run] + 60
31 AppKit 0x194823864 NSApplicationMain + 880
32 dyld 0x190c29058 start + 2224
Model: iMac21,2, BootROM 10151.1.1, proc 8:4:4 processors, 16 GB, SMC
Graphics: Apple M1, Apple M1, Built-In
Display: iMac, Retina 4.5K (4480 x 2520), Main, MirrorOff, Online
Memory Module: LPDDR4, Hynix
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x4378), wl0: Jul 8 2023 17:42:24 version 18.20.438.0.7.8.162 FWID 01-045ed435
AirPort:
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Ethernet Adapter (en4), Ethernet, en4
Network Service: Wi-Fi, AirPort, en1
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: USB3.1 Hub
USB Device: PSSD T7 Shield
USB Device: USB2.0 Hub
USB Device: Magic Trackpad
Thunderbolt Bus: iMac, Apple Inc.
Thunderbolt Bus: iMac, Apple Inc.
even i in a brand new macOS and install Xcode to upload apps to notarize, it crash anyway.
turns out you have to login your account in the appstoreconnect.apple.com to renew and agree all new agreements, once you did, Xcode stop crashes.